package ru.pashkan.spring.db.dao.springJdbc.mapper;

import org.springframework.jdbc.core.RowMapper;
import ru.pashkan.spring.entity.User;

import java.sql.ResultSet;
import java.sql.SQLException;

public class UserMapper implements RowMapper<User> {
    @Override
    public User mapRow(ResultSet resultSet, int i) throws SQLException {

        User user = new User();

        user.setUserId(resultSet.getInt("user_id"));
        user.setUserName(resultSet.getString("user_name"));
        user.setLogin(resultSet.getString("login"));
        user.setPassword(resultSet.getString("password"));
        user.setRegistrationDate(resultSet.getDate("registration_date"));
        user.setRoleId(resultSet.getInt("role_id"));
        user.setHide(resultSet.getBoolean("hide"));

        return user;
    }
}
